package com.yin.controller;

import java.util.Optional;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.yin.entity.UserEntity;
import com.yin.jpa.UserJPA;

/**
*@author LSY
*Time: 2018年12月26日上午11:29:45
*
*
*/
@RestController
@RequestMapping("/user")
public class UserController {

	@Autowired
	private UserJPA userJPA;
	@GetMapping(value = "/{id}")
	public UserEntity getUserById(@PathVariable Long id) {
		Optional<UserEntity> op = userJPA.findById(id);
		if(op.isPresent()) {
			return op.get();
		}
		return new UserEntity();
	}
}
